<template>
	<div class="mytest">
		<mescroll-vue ref="mescroll0" :up="getMescrollUp(0)" @init="mescrollInit0">
			<div id="dataList">
				<div class="everymytest" v-for="(item,index) in tab0.list">
					<div class="everycon">
						<div class="contop">
							<div class="concir"></div>
							<div class="conname">{{item.paper_name}}</div>
						</div>
						<div class="contime">答题时间：{{item.begin_time}}———{{item.end_time}}</div>
						<div class="conbut">
							<div class="conwrong">错题解析</div>
							<div class="conyes">全部解析</div>
						</div>
					</div>
				</div>
			</div>
		</mescroll-vue>
	</div>
</template>

<script>
	import MescrollVue from 'mescroll.js/mescroll.vue'
	export default {
		components: {
		  MescrollVue
		},
		data() {
			return {
				tabType: 0 ,// 菜单类型
				tab0: {mescroll: null, list: [], isListInit: false}, // 全部
			};
		},
		methods:{
			mescrollInit0 (mescroll) {
			  mescroll.tabType = 0; // 加入标记,便于在回调中取到对应的list
			  this.tab0.mescroll = mescroll;
			},
			
			getMescrollUp (tabType) {
			  return {
			    auto: true,
				callback: this.upCallback, // 上拉回调,此处可简写; 相当于 callback: function (page) { upCallback(page); }
				noMoreSize: 5, // 如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
				page:{
					num:-1
				},
				empty: {
					warpId: 'dataList', // 父布局的id;
					icon: 'static/img/nomytest.png', // 图标,默认null
					tip: '您还没有考试哦~', // 提示
				},
			  }
			},
			
			upCallback (page, mescroll) {
				var isLock = true;
				mescroll.lockDownScroll(isLock);
				// console.log(mescroll)
				var that = this;
				if (mescroll.tabType === 0) {
				// 全部
					that.tab0.isListInit = true;// 标记列表已初始化,保证列表只初始化一次
					var url = that.$store.state.url+'MyTk/myTest';
					var data = {
						page: page.num,
						limit:page.size
					}
					that.request.wxRequest('GET',url,data,function(res){
						if (res.data.errcode == 0 || res.data.errcode == '0') {
							var curPageData = res.data.data.cards;
							mescroll.endSuccess(curPageData.length);// 联网成功的回调,隐藏下拉刷新和上拉加载的状态;
							 if (page.num === 0) that.tab0.list = []; // 如果是第一页需手动制空列表
							 that.tab0.list = that.tab0.list.concat(curPageData); // 追加新数据
						}
					})
				}
		    }
		}
	}
</script>

<style scoped="scoped">
	.mytest{
		background: #FAFAFA;
	}
.everymytest{
	width: 100%;
	background: #fff;
	padding: .2rem 0;
	margin-top: .3rem;
}
.everycon{
	width: 6.9rem;
	margin: auto;
}
.contop{
	display: flex;
	justify-content: flex-start;
	align-items: center;
}
.concir{
	width: .12rem;
	height: .12rem;
	background: #0287FF;
	border-radius: 50%;
}
.conname{
	word-wrap:break-word;
	word-break:break-all;
	width: 90%;
	font-size: .3rem;
	font-weight: 600;
	color: #333333;
	margin-left: .18rem;
}
.contime{
	margin-top: .2rem;
	color: #999999;
	font-size: .24rem;
}
.conbut{
	margin-top: .23rem;
	display: flex;
	justify-content: flex-end;
}
.conbut div{
	width: 1.6rem;
	line-height: .48rem;
	text-align: center;
	border-radius: .08rem;
	color: #fff;
}
.conwrong{
	background: #FE2326;
}
.conyes{
	background: #0287FF;
	margin-left: .7rem;
}
</style>
